<?php

// $Id$


class TCMS_Attachment extends Tangra_Class {
	private $id;
	private $orig_filename;
	private $size = 0;
	private $path = '';
	private $filename = '';
	private $extension = '';
	private $note = '';


	public function set_id($id) {
		tangra_if_not_int_throw_e($id);

		$this->id = $id;
	}


	public function get_id() {
		return $this->id;
	}


	public function set_orig_filename($orig_filename) {
		$this->orig_filename = $orig_filename;
	}


	public function get_orig_filename() {
		return $this->orig_filename;
	}


	public function set_size($size) {
		tangra_if_not_int_throw_e($size);

		$this->size = $size;
	}


	public function get_size() {
		return $this->size;
	}


	public function set_path($path) {
		$this->path = $path;
	}


	public function get_path() {
		return $this->path;
	}


	public function set_filename($filename) {
		$this->filename = $filename;
	}


	public function get_filename() {
		return $this->filename;
	}


	public function set_extension($extension) {
		$this->extension = $extension;
	}


	public function get_extension() {
		return $this->extension;
	}


	public function set_note($note) {
		$this->note = $note;
	}


	public function get_note() {
		return $this->note;
	}


	public static function is_valid_extension($file_name, $forbidden_extensions_comma_list) {
		$ret = true;

		$last_dot = strrpos($file_name, '.');
		if ($last_dot !== false) {
			$file_extension = trim(substr($file_name, $last_dot + 1));
			$extensions_list = explode(',', $forbidden_extensions_comma_list);
			foreach($extensions_list as $ext) {
				if (strtolower(trim($ext)) == strtolower($file_extension)) {
					$ret = false;
					break;
				}
			}
		}

		return $ret;
	}
}